//
//  LeftMenuLogedInTableViewController.m
//  KYClient
//
//  Created by mac on 16/3/1.
//  Copyright © 2016年 com.gp123. All rights reserved.
//

#import "LeftMenuLogedInTableViewController.h"

#import "UIImageView+WebCache.h"
//#import "SettingAndHelpController.h"
//#import "UserInfoTableViewController.h"
#import "BaseNavigationController.h"
//#import "AboutProductController.h"
//#import "UMSocial.h"
//#import "FamousDoctorController.h"
//#import "ClinicHistoryManagerTableViewController.h"
//#import "SelectedViewController.h"
#import "YuYUTableViewController.h"
#import "BingLiGuanLiViewController.h"
#import "XiuGaiBingLIViewController.h"
#import "WoDeShouCangViewController.h"
#import "ShouZhiMingXiViewController.h"
#import "UserInfoModel.h"
#import "GHNetWorkTools.h"

@interface LeftMenuLogedInTableViewController ()<UIGestureRecognizerDelegate>
@property (weak, nonatomic) IBOutlet UILabel *userNameLabel;
@property (weak, nonatomic) IBOutlet UIImageView *userImageView;
@property (weak, nonatomic) IBOutlet UIView *navView;
@property (weak, nonatomic) IBOutlet UILabel *userInfo;

@end

@implementation LeftMenuLogedInTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //设置
    self.navView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"nav"]];
    //添加手势
    UITapGestureRecognizer * tapGesture =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapGesture)];
    [self.navView addGestureRecognizer:tapGesture];
    tapGesture.delegate=self;
    tapGesture.cancelsTouchesInView = NO;
    self.navigationController.navigationBarHidden = YES;
    
    [self setUserInfoModels];
}
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer  {
    return YES;
}
//隐藏状态条
//-(BOOL)prefersStatusBarHidden{
//    return YES;
//}
-(void)didTapGesture{
    NSLog(@"taptap跳转到个人信息页面");
   // UserInfoTableViewController  * userInfoVC = [[UserInfoTableViewController alloc]init];
    
    
    
    //BaseNavigationController * nav= [[BaseNavigationController alloc]initWithRootViewController:userInfoVC];
    //[self presentViewController:nav animated:YES completion:nil];
}
-(instancetype)init{
    if (self=[super init]) {
        //从storyBoard加载登陆后的控制器
        UIStoryboard * storyBoard =[UIStoryboard
                                    storyboardWithName:@"LeftMenu_login" bundle:nil];
        
        self = (LeftMenuLogedInTableViewController *) [storyBoard
                                                       instantiateViewControllerWithIdentifier:@"logedin"];
        
   //     [UserInfoModel userInfoWithSuccess:^(UserInfoModel *model) {
            
        //    self.userInfoModel = model;
            
    }
    error:^(NSError *error) {
            NSLog(@"%@",error);
    };
    return self;
}


-(void)setUserInfoModels{
    
    //设置用户名
    self.userNameLabel.text = [UserInfoModel shareUserInfoModel].username;
    self.userNameLabel.textColor = [UIColor blackColor];
   // self.userInfo.textColor = [UIColor  grayColor];
   // self.userInfo.text = [UserInfoModel shareUserInfoModel]
    //设置用户头像
    //[self.userImageView sd_setImageWithURL:[NSURL URLWithString:userInfoModel.head_photo] placeholderImage:[UIImage imageNamed:@"name"]];
    [self.userImageView setImage:[UIImage imageNamed:@"name"]];
    //设置显示成圆角头像
    self.userImageView.layer.masksToBounds=YES;
    self.userImageView.layer.cornerRadius = 17.5;
    

}




//点击cell要跳转的控制器

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    // 根据cell的indexPath 选择跳转的控制器====后期完善
    
    NSIndexPath * cellIndex = indexPath;
    
    if (cellIndex.section == 0) {
        switch (cellIndex.row) {
            case 0:
                //将要跳转的控制器-----预约列表
            {
                
                NSString *urlstr = @"getyuyueguahao";
                NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@([UserInfoModel shareUserInfoModel].userid),@"userid", nil];
                
                
                
                NSLog(@"%@",urlstr);
                [[GHNetWorkTools sharedTools] requestDataWith:GET urlString:urlstr parameters:dict finishedBlock:^(id result, NSError *error) {
                    NSLog(@"%@",result);
                    
                    YuYUTableViewController *vc = [[YuYUTableViewController alloc] init];

                    
                    vc.models = [result valueForKey:@"getyuyueguahao"];
                   // need.title = ;
                    //设置返回按钮样式
                  //  self.navigationItem.backBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:nil action:nil];
                   // [self.navigationController pushViewController:need animated:YES];
                    
                    BaseNavigationController * naVC = [[BaseNavigationController alloc]initWithRootViewController:vc];
                    
                    [self presentViewController:naVC animated:YES completion:nil];
                    
                }];

                
                
                
            }
                
                break;
            case 1:
                //将要跳转的控制器-----病例管理
            {
                BingLiGuanLiViewController *vc = [[BingLiGuanLiViewController alloc] init];
                
                BaseNavigationController * naVC = [[BaseNavigationController alloc]initWithRootViewController:vc];
                
                [self presentViewController:naVC animated:YES completion:nil];
            
            }
                break;
            case 2:
            { //将要跳转的控制器-----wodeshouchang
                WoDeShouCangViewController *vc = [[WoDeShouCangViewController alloc] init];
                BaseNavigationController * naVC = [[BaseNavigationController alloc]initWithRootViewController:vc];
                
                [self presentViewController:naVC animated:YES completion:nil];
            }
                break;
            case 3:
            { //将要跳转的控制器-----wodeshouchang
                ShouZhiMingXiViewController *vc = [[ShouZhiMingXiViewController alloc] init];
                BaseNavigationController * naVC = [[BaseNavigationController alloc]initWithRootViewController:vc];
                
                [self presentViewController:naVC animated:YES completion:nil];
            }
                break;
                
            default:
                break;
        }
    }else  if (cellIndex.section == 1) {
        switch (cellIndex.row) {
            case 0:
                //将要跳转的控制器-----设置与关注
            {
                XiuGaiBingLIViewController *vc = [[XiuGaiBingLIViewController alloc] init];
                BaseNavigationController * naVC = [[BaseNavigationController alloc]initWithRootViewController:vc];
                
                [self presentViewController:naVC animated:YES completion:nil];
            }
                break;
            case 1:
                //将要跳转的控制器-----关于产品
//            {
//                AboutProductController *aboutVC = [[AboutProductController alloc] init];
//                [self presentViewController:aboutVC animated:YES completion:nil];
//                
//            }
                break;
            case 2:
//                //将要跳转的控制器-----分享给好友
//            {
//                [UMSocialSnsService presentSnsIconSheetView:self
//                                                     appKey:@"56d97617e0f55a85dd002128"
//                                                  shareText:@"友盟社会化分享让您快速实现分享等社会化功能，http://umeng.com/social"
//                                                 shareImage:[UIImage imageNamed:@"icon.png"]
//                                            shareToSnsNames:@[UMShareToSina]
//                                                   delegate:nil];
//            }
                break;
                
            default:
                break;
        }
    
    
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
   
}


#pragma mark - Navigation
/*
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
